package com.mxx.tomcat;

import com.mxx.common.conv.JacksonConverter;
import com.mxx.tomcat.verification.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.List;

@Configuration
public class WebArgumentResolversConfigurer implements WebMvcConfigurer {
    @Autowired
    private ResponseWriter responseWriter;
    @Autowired
    private List<HttpMessageConverter<?>> converters;
    @Autowired
    private JacksonConverter jacksonConverter;


    @Override
    public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
        resolvers.add(new FormEntityValidateArgumentResolver(converters, jacksonConverter, responseWriter));
        resolvers.add(new FormValidateArgumentResolver(converters, jacksonConverter, responseWriter));
        resolvers.add(new UrlEntityValidateArgumentResolver(converters, jacksonConverter, responseWriter));
        resolvers.add(new UrlValidateArgumentResolver(converters, jacksonConverter, responseWriter));
        resolvers.add(new JsonEntityValidateArgumentResolver(converters, jacksonConverter, responseWriter));
        resolvers.add(new JsonValidateArgumentResolver(converters, jacksonConverter, responseWriter));
    }


}
